const enums = require('../../../enum/enums')
const utils = require('../../../common/utils')

const rule = {
    name: [{
            required: true,
            message: '名称不能为空'
        },
        {
            type: 'string',
            message: '名称必须为字符串'
        },
        {
            Length: 20,
            message: '名称长度不能超过20个字符'
        },
    ],
    key: [{
            required: true,
            message: '唯一键不能为空'
        },
        {
            type: 'string',
            message: '唯一键必须为字符串'
        },
        {
            Length: 20,
            message: '唯一键长度不能超过20个字符'
        },
    ],
    type: [{
            required: true,
            message: '类型不能为空'
        },
        {
            type: 'string',
            message: '类型必须为字符串'
        },
        {
            Length: 20,
            message: '类型长度不能超过20个字符'
        },
        {
            type: 'enum',
            enum: utils.enums.enumsToRuleEnumArray(enums.permission_type),
            message: '类型不合法'
        },
    ],
    component:[
        {
            required: true,
            message: '组件不能为空'
        },
        {
            type: 'string',
            message: '组件必须为字符串'
        },
        {
            Length: 20,
            message: '组件长度不能超过20个字符'
        },
    ],
    show:[
        {
            required: true,
            message: '状态不能为空'
        },
        {
            type: 'string',
            message: '状态必须为字符串'
        },
        {
            Length: 20,
            message: '状态长度不能超过20个字符'
        },
        {
            type: 'enum',
            enum: utils.enums.enumsToRuleEnumArray(enums.show_status),
            message: '状态值不合法'
        }
    ],
    sort:[
        {
            type: 'integer',
            message: '排序值必须为整数'
        },
    ],
};


module.exports = rule;